<extend name="work/base"/>
<block name="content">
<style>
    .help_li{
       line-height:32px;
        cursor:pointer;
    }
    .layui-collapse{
        margin-top: 15px;
    }
    .helpview{
        cursor:pointer;
    }
</style>
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md2">
            <div>
                <div class="layui-collapse">
                    <volist name="help_category" id="vo" key="k">
                        <eq name="vo.pid" value="0">
                            <div class="layui-colla-item ">
                                <h2 class="layui-colla-title">{$vo.title}</h2>
                                <div class="layui-colla-content ">
                                    <ul class="">
                        </eq>
                        <volist name="help_category" id="vo2" key="k">
                            <eq name="vo2.pid" value="$vo.id">
                                <li class="help_li" category="{$vo2.id}"> {$vo2.title}</li>
                            </eq>
                        </volist>

                        <eq name="vo.pid" value="0">
                            </ul>
                </div>
            </div>

            </eq>
            </volist>

        </div>
    </div>
    </div>
    <div class="layui-col-md10">
        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline dropdown">
                    <input name="title" class="layui-input" type="text" id="doctitle" placeholder="文档名称">
                </div>
                <div class="layui-inline">
                    <button class="layui-btn  layui-btn-normal" lay-submit lay-filter="docsearch_btn"><i
                            class="layui-icon">&#xe615;</i>搜索
                    </button>
                </div>

            </div>
        </form>
        <table class="layui-table " id="list" lay-filter="list"
               list-url="{:url('/help/lists')}"
               edit-url="{:url('helpedit')}"
               del-url="{:url('helpdelete')}"
               forms-url="{:url('helpview')}"
        ></table>
    </div>

    </div>

</block>
<block name="script">
    <script type="text/javascript">
        layui.use(['element', 'table', 'form', 'tree','layer'], function () {
            var table = layui.table
                , element = layui.element
                ,$=layui.$
                ,layer=layui.layer
                , form = layui.form;
            table.render({
                elem: '#list'
                , url: "{:Url('/help/lists')}"
                , page: true
                , loading: true
                , limit: 20
                ,page:{
                    layout: ['prev','page', 'next' ]
                    ,theme: '#1E9FFF'
                }
                , cols: [[
                    {field: 'title',  templet: '<div><a class="helpview" ">{{d.title}}</a></div>'}
                ]]
            });
            //监听行单击事件（双击事件为：rowDouble）
            table.on('row(list)', function(obj){
                var data = obj.data;

                //页面层
                layer.open({
                    type: 2,
                    title:'知识库',
                    skin: 'layui-layer-rim', //加上边框
                    area: ['800px','800px'], //宽高
                    content: ['{:url("/help/helpview","","",true)}/id/'+data.id]
                });
            });

            $('.help_li').click(function () {
                caregory=$(this).attr('category');
                table.reload('list', {
                    url: "{:Url('/help/lists')}"
                    ,page: {
                        curr: 1
                    }
                    , where: {
                        category_id:caregory
                    } //设定异步数据接口的额外参数
                    //,height: 300
                });
            })



            //监听单元格事件
            form.on('submit(docsearch_btn)', function (data) {
                table.reload('list', {
                    url: "{:Url('/help/lists')}"
                    , page: {
                        curr: 1
                    }
                    , where: data.field
                });
                return false;
            });
            form.on('select(doc_type)', function (data) {
                table.reload('list', {
                    url: "{:Url('/help/lists')}"
                    , page: {
                        curr: 1
                    }
                    , where: {
                        status: data.value
                    }
                });
                return false;
            });
        });
    </script>
</block>
